#!/bin/bash


>red.txt
>blu.txt
>zhongjian_red.txt
>zhongjian_blu.txt
>shuru_red.txt
>shuru_blu.txt
for i in `seq 33`
do
echo "$i" >>red.txt
done
red_sz=($(cat red.txt|sort -n))
echo "${red_sz[*]}"
echo 
for n in `seq 16`
do
echo  "$n" >> blu.txt
done
blu_sz=($(cat blu.txt))
#绿色中奖的号码
l_zj=$((RANDOM%${#blu_sz[@]}))
echo "${blu_sz[l_zj]}" >>zhongjian_blu.txt

#红色中奖的号码

for m in {1..5}
do
	r_zj=$((RANDOM%${#red_sz[@]}))
	echo "${red_sz[r_zj]}" >>zhongjian_red.txt
	unset red_sz[$r_zj]
	red_sz=($(echo "${red_sz[*]}"))
done
	cat zhongjian_red.txt|sort -n >zj_red.txt

echo "中奖的数红球"
cat zj_red.txt
echo "中奖的蓝球"
cat zhongjian_blu.txt
for m in `seq 6`
do
	if (( $m == 6 ))
	then
		echo -n "绿色的数有 ${blu_sz[@]}"
		read -p "请输入绿球的数:" blu
		echo $blu >>shuru_blu.txt
	else
		echo "红色的数有 ${red_sz[*]}"
		echo "第$m 个红球的数"
		read  red
		echo $red >>shuru_red.txt
	fi
done
cat shuru_red.txt|sort -n >red_sr.txt
	diff red_sr.txt zj_red.txt &>/dev/null
	if [ $? == 0 ]
	then
		diff shuru_blu.txt zhongjian_blu.txt &>/dev/null
		if [ $? == 0 ]
		then
			echo "恭喜你中奖了，五百万等你来拿"
		else
			echo "红球输入正确"
		fi
	else
		echo "差距有点大，请继续"
	fi
